import {
    getmessagerechargehistoryapi
} from '../../api/message'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        pageNum: 1,
        pageSize: 20,
        hasNextPage: true,
        list: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {},
    onShow() {
        this.setData({
            list:[],
            pageNum:1
        })
        this.getmessagerechargehistory()
    },
    async getmessagerechargehistory() {
        let res = await getmessagerechargehistoryapi({
            pageNum: this.data.pageNum,
            pageSize: this.data.pageSize
        })
        console.log(res);
        let carr = this.data.list.concat(res.list)
        console.log(carr);
        this.setData({
            list: carr,
            hasNextPage: res.hasNextPage
        })
    },
    rechargeWechat() {
        // wx.showToast({
        //     title: '功能维护中',
        //     icon: 'none'
        // })
        // console.log('微信充值');
        // return
        wx.navigateTo({
            url: '/packageMassmessage/pages/message-wechat/message-wechat',
        })
    },
    rechargeGtg() {
        console.log('公对公');
        wx.navigateTo({
            url: '/packageMassmessage/pages/message-business/message-business',
        })
    },
    rechargedetail(e) {
        console.log(e);
        wx.navigateTo({
            url: '../message-recharge-success/message-recharge-success?id=' + e.currentTarget.dataset.id,
        })
    },
    onReady() {

    },
    
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
        if (this.data.hasNextPage) {
            this.setData({
                pageNum: this.data.pageNum + 1
            })
            console.log(this.data.pageNum);
            this.getmessagerechargehistory()
        } 
        // else {
        //     wx.showToast({
        //         title: '暂无更多充值记录',
        //         icon: 'none'
        //     })
        // }
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})